<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>按钮</button>
  <script>
    // function foo() {
    //   "abc".filter() // 一旦错误下边都不会再执行
    //   console.log("这里还有代码");
    //   console.log("--------");
    // }
    // foo()
    // console.log("+++++++++");

    // const btn = document.querySelector("button")
    // btn.onclick = function () {
    //   console.log("监听btn按钮的点击");
    // }

    // 封装一个工具，在传入参数类型不正确的时候抛出异常
    function sum(num1, num2) {
      if (typeof num1 != "number") {
        throw "num1 的类型必须是number类型"
      }

      if (typeof num2 != "number") {
        throw "num2 的类型必须是number类型"

      }

      return num1 + num2
    }

    sum(123, "3456")
  </script>
</body>

</html>